var connection_ios = function(eventHandler, messageHandler) {
	function connectWebViewJavascriptBridge(callback) {
		if (window.WebViewJavascriptBridge) {
			callback(WebViewJavascriptBridge)
		} else {
			document.addEventListener('WebViewJavascriptBridgeReady',
					function() {
						callback(WebViewJavascriptBridge)
					}, false)
		}
	}
	connectWebViewJavascriptBridge(function(bridge) {
		var uniqueId = 1
		function log(message, data) {
			var log = document.getElementById('log')
			var el = document.createElement('div')
			el.className = 'logLine'
			el.innerHTML = uniqueId++ + '. ' + message + ':<br/>'
					+ JSON.stringify(data)
			if (log.children.length) {
				log.insertBefore(el, log.children[0])
			} else {
				log.appendChild(el)
			}
		}
		bridge.init(function(message, responseCallback) {
			if (messageHandler != null) {
				messageHandler(message, responseCallback);
			}
			// log('JS got a message', message)
			// var data = {
			// 'Javascript Responds' : 'Wee!'
			// }
			// log('JS responding with', data)
			// responseCallback(data);

		});
		eventHandler(bridge);
	});
};
